<template>
  <j-modal :title="title" :width="600" :visible="visible" :maskClosable="false" @ok="handleOk" @cancel="handleCancel">
    <a-form :form="form">
      <a-form-item label="数据说明" :labelCol="labelCol" :wrapperCol="wrapperCol">
        <a-textarea v-decorator="['dataComment']" placeholder="数据补传请填写原因" rows="4" style="width: 100%" />
      </a-form-item>
    </a-form>
  </j-modal>
</template>

<script>

export default {
  name: 'ReasonModal',
  data() {
    return {
      title: '数据说明',
      visible: false,
      form: this.$form.createForm(this),
      labelCol: {
        xs: { span: 24 },
        sm: { span: 6 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      record: null
    }
  },
  methods: {
    show(record) {
      this.visible = true;
      this.record = record;
      this.form.resetFields();
    },
    close() {
      this.visible = false;
      this.record = null;
      this.form.resetFields();
    },
    handleOk() {
      this.form.validateFields((err, values) => {
        if (!err) {
          this.record.dataComment = values.dataComment;
          this.$emit('ok', this.record);
          this.close();
        }
      });
    },
    handleCancel() {
      this.close();
    }
  }
}
</script>

<style scoped></style>